package com.moxiao.yfjh.module.blind.dal.mysql.comment;

import com.moxiao.yfjh.module.blind.controller.admin.comment.vo.MemberCommentExportReqVO;
import com.moxiao.yfjh.module.blind.controller.admin.comment.vo.MemberCommentPageReqVO;
import java.util.*;

import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import com.moxiao.yfjh.module.blind.dal.dataobject.comment.MemberCommentDO;
import org.apache.ibatis.annotations.Mapper;
import com.moxiao.yfjh.module.blind.controller.admin.comment.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 相亲会员评价 Mapper
 *
 * @author mx
 */
@Mapper
public interface MemberCommentMapper extends BaseMapperX<MemberCommentDO> {

    default PageResult<MemberCommentDO> selectPage(MemberCommentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberCommentDO>()
                .eqIfPresent(MemberCommentDO::getNo, reqVO.getNo())
                .eqIfPresent(MemberCommentDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MemberCommentDO::getContent, reqVO.getContent())
                .eqIfPresent(MemberCommentDO::getMomentId, reqVO.getMomentId())
                .eqIfPresent(MemberCommentDO::getMomentUser, reqVO.getMomentUser())
                .betweenIfPresent(MemberCommentDO::getCommentTime, reqVO.getCommentTime())
                .eqIfPresent(MemberCommentDO::getImgUrl, reqVO.getImgUrl())
                .eqIfPresent(MemberCommentDO::getVideoUrl, reqVO.getVideoUrl())
                .eqIfPresent(MemberCommentDO::getStatus, reqVO.getStatus())
                .eqIfPresent(MemberCommentDO::getMomentNo, reqVO.getMomentNo())
                .eqIfPresent(MemberCommentDO::getMomentContent, reqVO.getMomentContent())
                .eqIfPresent(MemberCommentDO::getAuitUser, reqVO.getAuitUser())
                .betweenIfPresent(MemberCommentDO::getAuitTime, reqVO.getAuitTime())
                .eqIfPresent(MemberCommentDO::getRejectReason, reqVO.getRejectReason())
                .betweenIfPresent(MemberCommentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MemberCommentDO::getId));
    }

    default List<MemberCommentDO> selectList(MemberCommentExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MemberCommentDO>()
                .eqIfPresent(MemberCommentDO::getNo, reqVO.getNo())
                .eqIfPresent(MemberCommentDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MemberCommentDO::getContent, reqVO.getContent())
                .eqIfPresent(MemberCommentDO::getMomentId, reqVO.getMomentId())
                .eqIfPresent(MemberCommentDO::getMomentUser, reqVO.getMomentUser())
                .betweenIfPresent(MemberCommentDO::getCommentTime, reqVO.getCommentTime())
                .eqIfPresent(MemberCommentDO::getImgUrl, reqVO.getImgUrl())
                .eqIfPresent(MemberCommentDO::getVideoUrl, reqVO.getVideoUrl())
                .eqIfPresent(MemberCommentDO::getStatus, reqVO.getStatus())
                .eqIfPresent(MemberCommentDO::getMomentNo, reqVO.getMomentNo())
                .eqIfPresent(MemberCommentDO::getMomentContent, reqVO.getMomentContent())
                .eqIfPresent(MemberCommentDO::getAuitUser, reqVO.getAuitUser())
                .betweenIfPresent(MemberCommentDO::getAuitTime, reqVO.getAuitTime())
                .eqIfPresent(MemberCommentDO::getRejectReason, reqVO.getRejectReason())
                .betweenIfPresent(MemberCommentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MemberCommentDO::getId));
    }

    @Select("select count(*) num from blind_member_comment where no = #{commentNo}")
    Integer getMemberCommentNo(@Param("commentNo") String commentNo);


}
